package com.chenglu.android.payment.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.common.utils.GlideUtils;
import com.chenglu.android.common.utils.LogUtils;
import com.chenglu.android.common.utils.Utils;
import com.chenglu.android.payment.ComfirmOrderActivity;
import com.chenglu.android.payment.bean.ComfirmOrderBean;


import java.util.List;

/**
 * @author: lyj
 * @Created: by Copyright 2023/3/29 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：确认订单布局
 */
public class ComfirmOrderItemAdapter extends BaseQuickAdapter<ComfirmOrderBean.Data.OrderBatchShopVOList.OrderGoodsDTOList, BaseViewHolder> {

    ComfirmOrderActivity comfirmOrderActivity;

    public ComfirmOrderItemAdapter(ComfirmOrderActivity context, int layoutResId, @Nullable List<ComfirmOrderBean.Data.OrderBatchShopVOList.OrderGoodsDTOList> data) {
        super(layoutResId, data);
        this.comfirmOrderActivity = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper,ComfirmOrderBean.Data.OrderBatchShopVOList.OrderGoodsDTOList item) {
        helper.setText(R.id.tv_cart_goodsName, item.getGoodsName());
        ImageView imageView = helper.getView(R.id.iv_cart_goodsImg);

        GlideUtils.setImageView(comfirmOrderActivity,item.getGoodsImg(),imageView,8);
        TextView tvGoodsNumber = helper.getView(R.id.tv_goods_number);
        tvGoodsNumber.setText("X"+item.getAmount());

        if(item.getGoodsSkus().isEmpty()){
            helper.setText(R.id.tv_cart_goodsTotalPrice,Utils.doubleTrans2(item.getGoodsPrice()));
        }else {
            helper.setText(R.id.tv_cart_goodsTotalPrice,Utils.doubleTrans2(item.getGoodsSkus().get(0).getGoodsPrice()));
        }

//
        if(!item.getGoodsSkus().isEmpty()){

            String datas =item.getGoodsSkus().get(0).getSpec().replace("{" ,"")
                    .replace("}","").replaceAll("\""," ");

            helper.setText(R.id.tv_cart_goodsSpec, datas).setGone(R.id.tv_cart_goodsSpec,true);
        }

//


    }
}
